package com.example.apiproject.controller;

import com.example.apiproject.entity.JoinArticle;
import com.example.apiproject.service.JoinArticleService;
import com.example.apiproject.utils.R;
import org.apache.ibatis.annotations.Update;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/joinArticle")
public class JoinArticleController {

    @Autowired
     private JoinArticleService joinArticleService;

    /**
     * 加入寻搭，默认未加入
     * @param request
     * @param id
     * @return
     */
    @PostMapping("/signUp")
    public R add(int userId,String id){
        return R.ok().put("result",joinArticleService.add( userId,id));
    }

    /**
     * 修改状态为已加入，即对方同意自己的搭子申请
     * @param joinArticle
     * @return
     */
    @PutMapping("/status")
    public R update(@RequestBody JoinArticle joinArticle){
        return R.ok().put("result",joinArticleService.update(joinArticle));

    }
}
